home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #42 (Mar 89) / XCMD CODE / adspxcmd.p next >
Text File  |  1989-01-10  |  6KB  |  148 lines

  1. (********************************************************************)
  2. (*    file:         ADSPxcmd.p                                            *)
  3. (*    version:    .01ß                                                 *)
  4. (*                                                                     *)
  5. (* ----------------------------------------------------------------    *)
  6. (* By:    Donald Koscheka    and Nancy Rosenberg                            *)
  7. (* Date:    1-Feb-88                                                *)
  8. (* ©    Copyright 1988, Apple Computer, Inc.                        *)
  9. (*    All Rights Reserved                                                *)
  10. (*                                                                    *)
  11. (* ----------------------------------------------------------------    *)
  12. (*                        Modification History                        *)
  13. (* ----------------------------------------------------------------    *)
  14. (*  Date           | By    |                     Description                *)
  15. (* ----------------------------------------------------------------    *)
  16. (*  1-Feb-88    | DK    | file created                                *)
  17. (* 13-May-88    | DK    | Added user area to connection record        *)
  18. (* 13-May-88    | DK    | Added File Transfer Record                *)
  19. (* ----------------------------------------------------------------    *)
  20. (********************************************************************)
  21.  
  22. UNIT adspxcmd;
  23.  
  24. INTERFACE
  25.  
  26. USES    Memtypes, QuickDraw, OSIntf, ToolIntf, AppleTalk, ADSP;
  27.  
  28.  
  29. CONST
  30.  
  31. ASYNC             = TRUE;
  32. SYNC            = FALSE;
  33.  
  34. {*** connection mode status ***}
  35. NOP                = 0;
  36. REQ                = 1;
  37. ACK                = 2;
  38. EST                = 3;
  39.  
  40. GLOBALNBPDATA    = 28400;
  41. GLOBALDSPDATA    = 29337;
  42. GLOBALSKTDATA    = 21644;
  43. DEFAULT_ERROR    = 23220;
  44. NO_ERROR        = 22476;
  45. MEM_ERROR        = 31830;
  46. NBPLSIZE        = 120;
  47. ATPBSIZE        = 578;        {  the standard size of a "transaction" buffer            }
  48.  
  49. INTERVAL        = 20;        {  default retry interval  60 ticks = 10 secs.            }
  50. RETRY            = 3;        {  retry count = 3: total = 3 * 60 = 30 secs.             }
  51.  
  52. PORTBUSE        = $291;
  53. SPCONFIG        = $1FB;
  54.  
  55. CLOSE_OK        = 0;
  56. RECEIVING        = 1;
  57. CLOSE_NOW        = 2;
  58.  
  59. NEWLINE            = $0D;        {  inserted after each entry in the zone info table        }
  60.  
  61. aTalkVars        = $2D8;        { pointer to appletalk vars, aka aBusVars, mppVars        }
  62. sysABridge        = $19;         { Node address of a bridge [byte]                        }
  63. sysNetNum        = $1A;         { This node's network number [word]                        }
  64.  
  65. {******** File Transfer Protocol ************}
  66. NO_FORK            = 0;        { Currently not sending any data                        }
  67. DATA_FORK        = 1;        { Currently sending the data fork of the file            }
  68. RESOURCE_FORK    = 2;        { Currently sending the resource fork of the file        }
  69. FINDER_FORK        = 3;        { Currently sending the finder bytes of a file            }
  70.  
  71. FILE_NOT_READY    = 0;        { Not ready to send the file yet                        }
  72. FILE_READY        = 1;        { ready to receive the file                                }
  73.  
  74. (************************************************************************************)
  75. (* As long as you're asking...                                                        *)
  76. (*                                                                                    *)
  77. (* The following data blocks reference memory pointers rather than handles. This is    *)
  78. (* not an intentionally egregious use of the memory manager but rather a way to     *)
  79. (* insure that all of the data in the connection  block is non-relocatable since     *)
  80. (* ADSP runs asynchronously, the data must always be presented to ADSP.  Hypercard    *)
  81. (* doesn't seem to mind non-rels and tends to do a fairly good job of concatenating    *)
  82. (* them low in the heap (Hypercard is no slouch when it comes to nonrels either, so    *)
  83. (* we're just piggybacking our pointers on top of the large nonrel area at the start*)
  84. (* of the Hypercard application heap). ça ne fait rien.                                *)
  85. (************************************************************************************)
  86.  
  87. TYPE
  88.  
  89. LIntPtr        = ^LongInt;
  90. IntPtr        = ^INTEGER;
  91.  
  92. CBPtr        = ^Connection;
  93. Connection  = Packed Record
  94.         next    : CBPtr;            { pointer to the next block in the list            }
  95.         last    : CBPtr;            { pointer to the last block in the list            }
  96.         ccbRef    : Integer;            { reference number for this connection             }
  97.         mode    : Integer;            { set to EST if the connection is open & ready    }
  98.         adr        : AddrBlock;        { address of remote end (NIL if not connected)    }
  99.         msg        : Handle;            { callback message for incoming data            }
  100.         sendQ    : Ptr;                { buffer for sending to remote connection end     }
  101.         recvQ    : Ptr;                { buffer for receiving from remote connection    }
  102.         attn    : Ptr;                { buffer for attention messages                    }
  103.         outBuf    : Handle;            { where the outgoing data is placed                }
  104.         inBuf    : Handle;            { where the input data goes                        }
  105.         attnBuf    : Handle;            { where the attention data goes                    }
  106.         remName    : Handle;            { the entity name of the remote end                }
  107.         ccb        : TRCCB;            { pointer to the connection control block        }
  108.         attnPB    : DSPParamBlock;    { attention messages parameter block            }
  109.         dspPB    : DSPParamBlock;    { connection param block for this connection    }
  110.         user    : Handle;            { place for user defined data.                    }
  111. End;
  112.  
  113.  
  114. ADSPPtr        = ^ADSPBlock;
  115. ADSPBlock     = Packed Record            { ADSP protocol data                            }
  116.         dspRefNum    : Integer;        { driver refnum for ADSP                         }
  117.         ccbref        : Integer;        { ccbRefNum for the connection listener            }
  118.         addr        : AddrBlock;    { socket address of this entity                    }
  119.         ends        : CBPtr;        { list of established connections                }
  120.         ccb            : TRCCB;        { ptr to listener connection control block        }
  121.         pb            : DSPParamBlock;{ parameter block for connection listener        }
  122.         checkPoint    : Integer;        { set if we're in a callback now                }
  123.         oldSelf        : Byte;            { old state of the self-send flag                }
  124.         pad            : Byte;            { keep em even, steven                            }
  125. End;
  126.  
  127.  
  128. NBPPtr        = ^NBPBlock;    
  129. NBPBlock     = Packed Record
  130.         Registered    : Integer;        { true if we are already registered                }
  131.         EntCount    : Integer;        { number of entities visible                    }
  132.         LookUpBuffer: Handle;        { handle to the lookup buffer                    }
  133.         NTEntry         : NamesTableEntry;    { entry into the names table                }
  134.         NBPLocal    : array[1..NBPLSIZE] of char;    { used internally by NBP        }
  135. END;
  136.  
  137.  
  138. FXPtr        = ^FXRecord;        
  139. FXRecord    = Packed Record            { File Transfer Record.                            }
  140.         Status        : Integer;        { state of the current connection                }
  141.         Fork        : Integer;        { current for being transferred                    }
  142.         FilePtr        : Ptr;            { Data buffer for the transfer                    }
  143.         refNum        : Integer;        { reference id to the file                         }
  144.         Name        : Str255;        { file name                                        }
  145.         io            : paramBlockRec;{ io parameter block for the i/o                }
  146. END;
  147.  
  148. End.